<plugin>
    <script>
        import picker from '@windy/picker';
        import utils from '@windy/utils';

        const readValues = () => {
            let { lat, lon, values, overlay } = picker.getParams();
            // -> 50.4, 14.3, 'wind', [ U,V, ]

            console.log('Picker is at', lat, lon);

            if (overlay === 'wind') {
                let windObject = utils.wind2obj(values);
                console.log(windObject);
            } else if (/weaves|swell/.test(overlay)) {
                let wavesObject = utils.wave2obj(values);
                console.log(wavesObject);
            }
        };

        // picker has been opened at latLon coords
        picker.on('pickerOpened', readValues);

        // picker was dragged by user to latLon coords
        picker.on('pickerMoved', readValues);

        // picker was closed
        picker.on('pickerClosed', () => {
            console.log('Picker was closed');
        });
    </script>
</plugin>
